package sounds;



import matrix.world.volleyball.R;
import android.content.Context;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;

public class MyMedia {

	private static SoundPool sounds;
	
	private static int ball;
	private static int move;
	private static int main;
	
	public static void loadSound(Context context) {
		sounds = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
		ball = sounds.load(context, R.raw.ball, 1);
		move = sounds.load(context, R.raw.ball, 1);
		main = sounds.load(context, R.raw.mainsound, 1);
	}
	
	private MediaPlayer mp = null;
	public Context context = null;
	
	public MyMedia(Context context){
		this.context = context;
	}
	
	public static void playBall() {
	    sounds.play(ball, 0.2f, 0.2f, 1, 0, 1);
	}
	
	public static void playMove() {
	    sounds.play(move, 0.08f, 0.08f, 1, 0, 1);
	}

	public static void playMain(){
		sounds.play(main, 0.2f, 0.2f, 1, 0, 1);
	}
	
	public void playSound(int sFile) {
		final int medFile = sFile;
		Thread thread = new Thread(new Runnable() {
			public void run() {
				mp = MediaPlayer.create(context, medFile);
				mp.start();
			}
		});
		thread.start();
	}
}
